package com.jbm.core.client.remote;

import com.jbm.core.client.MainCallback;
import com.jbm.core.common.AccountCtrl;
import com.jbm.core.common.ConnectAgent;
import com.jbm.core.common.MainServer;
import com.jbm.core.iface.IAcross;
import com.jbm.core.iface.IConnectAgent;


/**
 * Created by root on 17-3-5.
 */
public class RIConnectAgent extends IConnectAgent
{
	public RIConnectAgent()
	{
	}

	public RIConnectAgent(IAcross ia)
	{
		super(ia);
	}

	public IAcross PushCA()
	{
		if ( MainServer.getG_server().getM_server_type() == MainServer.Server_type_Client )
		{
			ConnectAgent proxy = AccountCtrl.g_accountctrl.GetCA(AccountCtrl.Account_Server_id, "app_server");

			ConnectAgent ca = new ConnectAgent((IConnectAgent) m_input, MainServer.Server_type_Client, proxy, MainServer.getG_server().getM_localport());

			AccountCtrl.g_accountctrl.PushPoint(((IConnectAgent) m_input).getM_acc_id_4_arcross(), ca);

//		System.out.println(m_pbcontent.toString());

			return new IAcross(200, "OK");
		}else
			return new IAcross(200, "Force Client");
	}

	public IAcross OfflineCA()
	{
		if ( MainServer.getG_server().getM_server_type() == MainServer.Server_type_Client )
		{
			ConnectAgent proxy = AccountCtrl.g_accountctrl.GetCA(AccountCtrl.Account_Server_id, "app_server");

			ConnectAgent ca = new ConnectAgent((IConnectAgent) m_input, MainServer.Server_type_Client, proxy, MainServer.getG_server().getM_localport());

			AccountCtrl.g_accountctrl.OfflinePoint(((IConnectAgent) m_input).getM_acc_id_4_arcross(), ca);

//		System.out.println(m_pbcontent.toString());

			return new IAcross(200, "OK");
		}else
			return new IAcross(200, "Force Client");
	}

	public IAcross belogout()
	{
		MainServer.getG_server().cancellogin();
		MainCallback callback = MainServer.getG_server().getM_maincallback();

		if ( callback != null )
		{
			callback.Belogout();
		}
		return new IAcross(200,"OK");
	}
}
